<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "https://github.com/rbatis/rbatis_sql/raw/main/mybatis-3-mapper.dtd">
<mapper>
    <sql id="select_self">(id,user_id,role_id,create_time)</sql>

    <insert id="insert_batch">
        insert into user_role
        <include refid="select_self"></include>
        <foreach collection="array" index="key" item="item" open="(" close=")" separator=",">
            values #{item}
        </foreach>
    </insert>
    <select id="select_by_condition">
        select * from user
        <where>
            <if test="user_id != ''">
                and user_id =#{user_id}
            </if>
            <if test="role_id !=''">
                and role_id = #{user_id}
            </if>
        </where>
    </select>
</mapper>